<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <!-- 浏览器的预览设置 -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <!--    样式-->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css"
          th:href="@{https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css}">
    <link rel="stylesheet" href="../../static/css/me.css"
          th:href="@{/static/css/me.css}">
    <!--    js-->
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"
            th:src="@{https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js}"></script>
    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"
            th:src="@{https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js}"></script>

    <title>博客管理</title>
</head>
<body>

<!--导航栏-->
<!-- 分隔-->
<nav class="ui inverted vertical segment m-padded-tb-mini m-shadow-small">
    <!--    容器-->
    <div class="ui container">
        <!--菜单（无分割线），stackable响应移动端,可堆叠-->
        <div class="ui inverted secondary stackable menu">
            <!--            标题元素-->
            <h2 class="ui blue header item">管理后台</h2>
            <!--            元素-->
            <a href="#" th:href="@{/admin/blogs}" class="m-item item m-mobile-hide active" ><i class="home icon"></i>博客</a>
            <!--       active所在页面选项-->
            <a href="#" th:href="@{/admin/types}" class="m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
            <a href="#" th:href="@{/admin/tags}" class="m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
<!--            m-item作为点击事件的一个标记-->
            <div class="right m-item m-mobile-hide menu">
                <div class="ui dropdown item">
                    <div class="text">
                        <img src="https://picsum.photos/id/200/400/400"
                             th:src="@{https://picsum.photos/id/200/400/400}"
                             alt=""
                             class="ui avatar image">
                        黄程福
                    </div>
<!--                    注销-->
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" th:href="@{/admin/logout}" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show ">
        <i class="sidebar icon"></i>
    </a>
</nav>

<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right aligned menu">
            <a href="#" th:href="@{/admin/blogs/add}" class="item" >发布</a>
            <a href="#" th:href="@{/admin/blogs}" class="active teal item">列表</a>
        </div>
    </div>
</div>

<!--中间内容-->
<div class="m-container-small m-padded-tb-large stackable">
    <div class="ui container">
        <div class="ui segment">
            <div id="table-container">
                <form action="#" method="post" class="ui form">
                    <div class="inline fields">
                        <div class="inline field">
                            <div class="ui selection dropdown">
                                <input type="hidden" name="typeId">
                                <i class="dropdown icon"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                    <div th:each=" types : ${typeAll}"
                                         class="item" data-value="1"
                                         th:data-value="${types.id}"
                                         th:text="${types.name}">错误日志</div>
                                </div>
                            </div>
                        </div>
                        <div class="field">
                            <button class="ui mini teal basic button"><i class="search icon"></i>搜索</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>

        <div class="ui fluid vertical segment">
            <table th:fragment="blogList" class="ui celled striped table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>标题</th>
                    <th>类型</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="blog,blogState : ${pageInfo.list}">
                    <td th:text="${blogState.count}">1</td>
                    <td th:text="${blog.title}">大圣，此去欲何?</td>
                    <td th:text="${blog.getType().name}">我的故事</td>
                    <td th:text="${blog.updateTime}">2020-01-02 05:20</td>
                    <td>
                        <a href="#" th:href="@{/admin/blogs/update/{id} (id = ${blog.getId()})}" class="ui mini teal basic button">编辑</a>
                        <a href="#" th:href="@{/admin/blogs/delete/{id} (id = ${blog.getId()})}"
                           onclick="return confirm('确定要删除该文章吗？')"
                           class="ui mini red basic button">删除</a>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <!--                colspan合并列-->
                <tr>
                    <th colspan="6">
                        <div th:if="${pageInfo.pages}>1">
                            <a class="item" th:href="@{/admin/blogs(pageNum=${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1)}" th:unless="${pageInfo.isFirstPage}">上一页</a>
                            <a class="item" th:href="@{/admin/blogs(pageNum=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages})}" th:unless="${pageInfo.isLastPage}">下一页</a>
                        </div>
                        <a href="#" th:href="@{/admin/blogs/add}"  class="ui mini right floated teal basic button">新增</a>
                    </th>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
<!--底部footer-->
<!--分割线-->
<footer class="ui inverted vertical segment m-padded-tb-massive">
    <!--    容器-->
    <div class="ui left aligned container">
        <!--        有分割线的分组-->
        <div class="ui inverted divided grid stackable ">
            <div class="eight wide column">
                <!--                标题-->
                <h4 class="ui inverted header">联系我</h4>
                <!--                列表-->
                <div class="ui link list">
                    <p class="m-text-thin m-text-spaced m-opacity-mi">@邮箱：605908340@qq.com</p>
                    <p class="m-text-thin m-text-spaced m-opacity-mi">@联系电话：15659132375</p>
                </div>
            </div>
            <div class="four wide column">
                <h4>作者寄语</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mi">大家一起努力开始编程</p>
            </div>
            <div class="four wide column">
                <h4>对读者的祝福</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mi">祝福大家第一年就月薪过万</p>
            </div>
        </div>
    </div>
</footer>

<div class="ui center aligned inverted divided vertical segment stackable">
    <p class="m-text-thin m-text-spaced m-opacity-mi">版权@(黄程福)605908340@qq.com</p>
</div>

<!--点击事件-->
<script>
    // 获取.menu.toggle点击时
    $('.menu.toggle').click(function (){
        $('.m-item').toggleClass('m-mobile-hide');
    });
    $('.ui.dropdown').dropdown();

    // function loaddata() {
    //     $("#table-container").load(/*[[@{/admin/blogs/search}]]*/"/admin/blogs/search",{
    //         title : $("[name='title']").val(),
    //         typeId : $("[name='typeId']").val(),
    //         recommend : $("[name='recommend']").prop('checked'),
    //         page : $("[name='page']").val()
    //     });
    // }
</script>

</body>
</html>